<%@ page import="java.util.List" %>
<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2018/4/3
  Time: 16:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>执行增加数据</title>
</head>
<body>
<%

    if(session.getAttribute("isLogin")==null){
        response.sendRedirect("login.jsp");
    }

    request.setCharacterEncoding("utf-8");

    String username=request.getParameter("username");
    String password=request.getParameter("password");


    //链接数据库
    Connection connection=null;
    PreparedStatement preparedStatement=null;

    //注册数据库
    Class.forName("com.mysql.jdbc.Driver");
    //获取链接
    connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456"
            );

    //数据库指令
    String sql="insert into t_users(username,password) values(?,?)";

    //发送sql语句
    preparedStatement=connection.prepareStatement(sql);

    //插入到具体地方
    preparedStatement.setString(1,username);
    preparedStatement.setString(2,password);

    preparedStatement.executeUpdate();

    connection.close();
    preparedStatement.close();

%>


<%--<%@ include file="footer.jsp"%>--%>

<jsp:include page="footer.jsp">
    <jsp:param name="year" value="2018"/>
</jsp:include>
</body>
</html>
